package vista;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaListados extends javax.swing.JFrame {
	private JPanel jPanel1;
	private ButtonGroup buttonGroup2;
	private ButtonGroup buttonGroup1;
	private JButton btnsalir;
	private JButton btnlistar;
	private JTable tblListados;
	private JRadioButton rbtndes;
	private JRadioButton rbtnasc;
	private JRadioButton rbtnmas;
	private JButton btncancelar;
	private JRadioButton rbtnproducto;
	private JRadioButton rbtningrediente;
	private JPanel jPanel3;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaListados inst = new VistaListados();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VistaListados() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Listados");
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1);
				//jPanel1.setLayout(jPanel1Layout);
				jPanel1.setBounds(20, 27, 251, 108);
				jPanel1.setBorder(BorderFactory.createTitledBorder("Listados"));
				{
					rbtningrediente = new JRadioButton();
					jPanel1.add(rbtningrediente);
					rbtningrediente.setText("Ingredientes en Almacen");
					rbtningrediente.setActionCommand("Ingrediente");
					rbtningrediente.setPreferredSize(new java.awt.Dimension(215, 19));
					getButtonGroup1().add(rbtningrediente);
				}
				{
					rbtnproducto = new JRadioButton();
					jPanel1.add(rbtnproducto);
					rbtnproducto.setText("Productos Vendidos");
					rbtnproducto.setActionCommand("Productos");
					rbtnproducto.setPreferredSize(new java.awt.Dimension(215, 19));
					getButtonGroup1().add(rbtnproducto);
				}
				{
					rbtnmas = new JRadioButton();
					jPanel1.add(rbtnmas);
					rbtnmas.setText("Ingredientes mas Usados");
					rbtnmas.setActionCommand("Mas");
					rbtnmas.setPreferredSize(new java.awt.Dimension(212, 19));
					getButtonGroup1().add(rbtnmas);
				}
			}
			
			{
				jPanel3 = new JPanel();
				getContentPane().add(jPanel3);
				//jPanel3.setLayout(jPanel3Layout);
				jPanel3.setBounds(290, 27, 251, 106);
				jPanel3.setBorder(BorderFactory.createTitledBorder("Ordenar"));
				{
					rbtndes = new JRadioButton();
					jPanel3.add(rbtndes);
					rbtndes.setText("Descendentemente");
					rbtndes.setBounds(23, 62, 142, 19);
					rbtndes.setActionCommand("Des");
					rbtndes.setPreferredSize(new java.awt.Dimension(175, 19));
					getButtonGroup2().add(rbtndes);
				}
				{
					rbtnasc = new JRadioButton();
					jPanel3.add(rbtnasc);
					rbtnasc.setText("Ascendentemente");
					rbtnasc.setBounds(23, 20, 212, 19);
					rbtnasc.setActionCommand("Asc");
					rbtnasc.setPreferredSize(new java.awt.Dimension(174, 19));
					getButtonGroup2().add(rbtnasc);
				}
			}
			{
				TableModel tblListadosModel = 
					new DefaultTableModel(
							new String[][] { { "One", "Two" }, { "Three", "Four" } },
							new String[] { "Column 1", "Column 2" });
				tblListados = new JTable();
				getContentPane().add(tblListados);
				tblListados.setModel(tblListadosModel);
				tblListados.setBounds(20, 162, 520, 232);
			}
			{
				btnlistar = new JButton();
				getContentPane().add(btnlistar);
				btnlistar.setText("Listar");
				btnlistar.setBounds(101, 418, 91, 22);
				btnlistar.setActionCommand("Listar");
			}
			{
				btnsalir = new JButton();
				getContentPane().add(btnsalir);
				getContentPane().add(getJButton1());
				btnsalir.setText("Salir");
				btnsalir.setBounds(362, 418, 79, 22);
				btnsalir.setActionCommand("Salir");
			}
			pack();
			this.setSize(574, 481);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private ButtonGroup getButtonGroup1() {
		if(buttonGroup1 == null) {
			buttonGroup1 = new ButtonGroup();
		}
		return buttonGroup1;
	}
	
	private ButtonGroup getButtonGroup2() {
		if(buttonGroup2 == null) {
			buttonGroup2 = new ButtonGroup();
		}
		return buttonGroup2;
	}
	
	public void addlistener(ActionListener actionlistener){
    	rbtnasc.addActionListener(actionlistener);
    	rbtndes.addActionListener(actionlistener);
    	rbtningrediente.addActionListener(actionlistener);
    	rbtnproducto.addActionListener(actionlistener);
    	rbtnmas.addActionListener(actionlistener);
    	btnlistar.addActionListener(actionlistener);
    	btnsalir.addActionListener(actionlistener);
    	btncancelar.addActionListener(actionlistener);
    }
	
	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}

	public JTable getTblListados() {
		return tblListados;
	}

	public void setTblListados(JTable tblListados) {
		this.tblListados = tblListados;
	}
	
	private JButton getJButton1() {
		if(btncancelar == null) {
			btncancelar = new JButton();
			btncancelar.setText("Cancelar");
			btncancelar.setActionCommand("Cancelar");
			btncancelar.setBounds(228, 418, 106, 22);
		}
		return btncancelar;
	}

}
